<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<html>
	<body>
		<h1 class="pagetitle">
			新增/修改料号
		</h1>
		<div class="column1-unit">
		<script type="text/javascript">
			function checkInputData(){
				var partsUnion = "";
				var partsIds = document.getElementsByName('id');
				var quantitys = document.getElementsByName('quantity')
				
				for(var i = 0; i < partsIds.length;i++){
					if(quantitys[i].value != "" && quantitys[i].value != 0){
						partsUnion = partsUnion + partsIds[i].value  + "#" + quantitys[i].value + ":";
					}
				}
				alert(partsUnion);
				document.getElementById("pn.partsUnion").value = partsUnion;
				return true;
			}
		</script>
				<s:form method="post" action="pn!confirm.action"
					validate="true" theme="css_xhtml" onsubmit="return checkInputData()">
					
					<s:hidden id="pn.partsUnion" name="pn.partsUnion"></s:hidden>
					
					<s:if test=" pn.id != null"><s:hidden name="pn.id"></s:hidden></s:if>
					
						<table class="formtable">
							<tr>
								<th width="100">
									料号缩写
								</th>
								<td>
									<s:textfield  name="pn.pn" size="25" cssClass="validate[required,maxSize[25]]"></s:textfield>
								</td>
							</tr>
							<tr>
								<th>
									备注
								</th>
								<td>
									<s:textarea name="pn.remark" cssClass="validate[maxSize[100]] text-input"></s:textarea>
								</td>
							</tr>
						</table>
						
						<table class="bigtable" id="purchaseOrderSubTable">
							<tr>
								<th width="100">
								物料类别
								</th>
								<th width="100">
								物料名称
								</th>
								<th>
								数量
								</th>
							</tr>
							<s:iterator value="partsTypeList" status="pl">
								<tr <s:if test="#pl.even">class="tr-even"</s:if>>
								<td><s:property value="name"/></td>
								<td colspan="2">
									<table class="smalltable">
									<s:iterator value="partsList">
										<tr>
										<td width="100"><s:property value="name"/><s:hidden name="id"/></td>
										<td ><s:textfield name="quantity" size="5" cssClass="validate[custom[integer]]"></s:textfield></td>
										</tr>
									</s:iterator>
									</table>
								</td>
								</tr>
							</s:iterator>
						</table>
						<s:reset cssClass="button" theme="simple"></s:reset>
						<s:submit cssClass="button" theme="simple"></s:submit>
				</s:form>
		</div>

	</body>
</html>